<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='jslet-ui-DBDataLabel'>/**
</span> * @class 
 * @extend jslet.ui.DBFieldControl
 * 
 * DBDataLabel. Show field value in a HTML label. Example:
 * 
 *     @example
 *      var jsletParam = {type:&quot;DBDataLabel&quot;,dataset:&quot;employee&quot;,field:&quot;department&quot;};
 * 
 *     //1. Declaring:
 *      &lt;label data-jslet='type:&quot;DBDataLabel&quot;,dataset:&quot;employee&quot;,field:&quot;department&quot;' /&gt;
 *      or
 *      &lt;label data-jslet='jsletParam' /&gt;
 *
 *     //2. Binding
 *      &lt;label id=&quot;ctrlId&quot;  /&gt;
 *      //Js snippet
 *      var el = document.getElementById('ctrlId');
 *      jslet.ui.bindControl(el, jsletParam);
 *
 *     //3. Create dynamically
 *      jslet.ui.createControl(jsletParam, document.body);
 */
jslet.ui.DBDataLabel = jslet.Class.create(jslet.ui.DBFieldControl, {
<span id='jslet-ui-DBDataLabel-method-initialize'>	/**
</span>	 * @protected
	 * @override
	 */
	initialize: function ($super, el, params) {
		this.allProperties = 'styleClass,dataset,field';
		
		$super(el, params);
	},

<span id='jslet-ui-DBDataLabel-method-bind'>	/**
</span>	 * @protected
	 * @override
	 */
	bind: function () {
		this.renderAll();
		jQuery(this.el).addClass('form-control-static jl-datalabel jl-lbl-normal');//Bootstrap class
	},

<span id='jslet-ui-DBDataLabel-method-isValidTemplateTag'>	/**
</span>	 * @protected
	 * @override
	 */
	isValidTemplateTag: function (el) {
		return el.tagName.toLowerCase() == 'label';
	},
	
<span id='jslet-ui-DBDataLabel-method-doValueChanged'>	/**
</span>	 * @protected
	 * @override
	 */
	doValueChanged: function() {
		var Z = this,
			fldObj = Z._dataset.getField(Z._field);
		var text = Z.getText();
		Z.el.innerHTML = text;
		Z.el.title = text;
	},
	
<span id='jslet-ui-DBDataLabel-method-doLookupChanged'>	/**
</span>	 * @protected
	 * @override
	 */
	doLookupChanged: function() {
		this.doValueChanged();
	},

<span id='jslet-ui-DBDataLabel-method-renderAll'>	/**
</span>	 * @override
	 */
	renderAll: function () {
		this.refreshControl(jslet.data.RefreshEvent.updateAllEvent(), true);
		return this;
	},
	
<span id='jslet-ui-DBDataLabel-method-canFocus'>	/**
</span>	 * @protected
	 * @override
	 */
	canFocus: function() {
		return false;
	}
});

jslet.ui.register('DBDataLabel', jslet.ui.DBDataLabel);
jslet.ui.DBDataLabel.htmlTemplate = '&lt;label&gt;&lt;/label&gt;';

</pre>
</body>
</html>
